@isTest
private class pvvCtlr_Tests {

    public static testMethod void testMyController() //default and 30 day test
    {
        //centralized data create
    Account acc = cls_CreateTestRecords.createAccount(); 
      Country__c Countries = cls_CreateTestRecords.createCountries();
      Occupation__c OCP = cls_CreateTestRecords.createOccupation();
      Qualification__c QualificationsList = cls_CreateTestRecords.createQualiciation();
      Passport_Type__c pt = cls_CreateTestRecords.createPassportType();
      CountriesList__c CountriesList = cls_CreateTestRecords.createCountriesList();
        cls_CreateTestRecords.createFormRecords1(); 
         
        //Test defaults
        PageReference pageRef = Page.pvv;
        Test.setCurrentPage(pageRef);
        
        
        //Test One - load default options
        pvv_ctlr controller = new pvv_ctlr();
        List<SelectOption> TestOptions = new List<SelectOption>();
        //TestOptions = controller.getPassportTypes();
        TestOptions = controller.getCountries();
        TestOptions = controller.getCountriesList();
        TestOptions = controller.getCompanies();
        TestOptions = controller.getJobTitles();
        //TestOptions = controller.getQualifications();
        TestOptions = controller.getGenders();
        TestOptions = controller.getTitles();
        TestOptions = controller.getVisaPeriod();
        //TestOptions = controller.getHoldUAEPermit();
        TestOptions = controller.getMaritalStatuses();
        TestOptions = controller.getReligions();
        TestOptions = controller.getPortOfEntries();
        TestOptions = controller.getTitles();
        TestOptions = controller.getVisaPeriod();
        
        controller.testFlagMark();
        controller.ResetApplication();
        controller.ToMainMenu();
        
        //Load blank/default application data for validation
        controller.Application.Company_Name__c = acc.id;
        pvv_ctlr.WebParam = '';
        pvv_ctlr.stdemo = '';
    pvv_ctlr.Initializevariables();
    pvv_ctlr.GenerateBarcode();
    controller.geturl();
    controller.getsoapXML();
    controller.getxml();
        controller.CreateApplication(); //Blank values trigger validation addmessages
        
        
        //Test Two - target the else conditions from test one
        pvv_ctlr controllerTwo = new pvv_ctlr();
        
        //DATES
        string dateBirth  = String.valueOf(System.Today().addyears(1)); 
        dateBirth = string.valueOf(dateBirth.split('-')[2]+'/'+dateBirth.split('-')[1]+'/'+dateBirth.split('-')[0]);
        controllerTwo.dateOfBirth = dateBirth; 
        controllerTwo.passportIssueDate = String.ValueOf(Date.TODAY());          
        controllerTwo.passportExpiryDate = String.ValueOf(Date.TODAY());     
        //controllerTwo.companyDate = String.ValueOf(Date.TODAY());
        //INPUT DATA     
    controllerTwo.Application.TAMM_VIP_Service__c = true;
        controllerTwo.Application.Visa_Period__c = '30 Days';
        controllerTwo.Application.Hold_UAE_Permit__c = 'Yes';
        controllerTwo.application.Port_of_Entry__c = 'Dubai International Airport';
        controllerTwo.application.Title__c = 'Mr';
        controllerTwo.application.First_Name__c = 'Cloud';
        controllerTwo.application.Middle_Name__c = 'S';
        controllerTwo.application.Last_Name__c = 'Concept';
        controllerTwo.application.Currently_Nationality__c = Countries.id;
        controllerTwo.application.Previous_Nationality__c = Countries.id;
        controllerTwo.application.Country_of_Birth__c = CountriesList.id;
        controllerTwo.application.City_of_Birth__c = 'SomePlace';
        controllerTwo.Application.Passport_Type__c = pt.id;
        controllerTwo.application.Passport_Number__c = '2345678AS';
        controllerTwo.application.Passport_Country_of_Issue__c = CountriesList.id;
        controllerTwo.application.Passport_City_of_Issue__c = 'SOMECITY';        
        controllerTwo.application.Mother_Full_Name__c = 'SOMENAME';
        controllerTwo.application.Marital_Status__c = 'Married';
        controllerTwo.application.Religion__c = 'bahaei';
        controllerTwo.Application.Job_Title_Position__c = OCP.id;
        controllerTwo.Application.Education_Qualification__c = QualificationsList.id;
        controllerTwo.Application.Gender__c = 'female';
        controllerTwo.Application.Company_Name__c = acc.id;
        controllerTwo.Application.Company_Point_Of_Contact_Mobile_Number__c = '23456789';
        controllerTwo.Application.Company_Index_Card_Number__c = '123';
        controllerTwo.Application.Name_of_Authorized_Signatory__c = 'SOMEONE';
        controllerTwo.Application.VRF_Verify1__c = true;
        controllerTwo.Application.VRF_Verify2__c = true;
        controllerTwo.CreateApplication();
        
         //Test Three -  invalid data
        pvv_ctlr controllerThree = new pvv_ctlr();
        controllerThree.dateOfBirth = ('32/13/1700'); //Invalid Date          
        controllerThree.passportIssueDate = ('32/13/1700'); //Invalid Date          
        controllerThree.passportExpiryDate = ('32/13/1700'); //Invalid Date 
        //controllerThree.companyDate =  ('32/13/1700');        
        controllerThree.CreateApplication();       
        
    /*
        Form_Header__c Header = new Form_Header__c();
                Header = [SELECT id, Name, Barcode_Type__c, (SELECT id, Name, Field_Master__c, Field_Master__r.API_Name__c, Field_Master__r.Reference_To__c, Field_Master__r.Referencing_Value__c, Position__c, Tab_Space__c, Source__c, Default_Value__c, Default_Value__r.Value__c FROM Form_Details__r order by Position__c) From Form_Header__c WHERE Name = 'DIFC Business Visit Visa Form - Short Term' LIMIT 1];        
               
                
                for(Form_Detail__c Detail : Header.Form_Details__r)
            {
               system.debug('what does header name contain ' + Detail.Field_Master__r.API_Name__c);
            }
        
        
        SingleRequestMockup fakeResponse = new SingleRequestMockup(200,
                                                 'Complete',
                                                 '[{"Name": "sForceTest1"}]',
                                                 null);
    Test.setMock(HttpCalloutMock.class, fakeResponse);
        */
  

     
    }

  
    public static testMethod void testMyController2() // 30 day test
    {
         //centralized data create
    Account acc = cls_CreateTestRecords.createAccount(); 
      Country__c Countries = cls_CreateTestRecords.createCountries();
      Occupation__c OCP = cls_CreateTestRecords.createOccupation();
      Qualification__c QualificationsList = cls_CreateTestRecords.createQualiciation();
      Passport_Type__c pt = cls_CreateTestRecords.createPassportType();
      CountriesList__c CountriesList = cls_CreateTestRecords.createCountriesList();
        //cls_CreateTestRecords.createFormRecords1(); 
        
 
        PageReference pageRef = Page.pvv;
        Test.setCurrentPage(pageRef);
        
        pvv_ctlr controller = new pvv_ctlr();
        
        List<SelectOption> TestOptions = new List<SelectOption>();
        //TestOptions = controller.getPassportTypes();
        TestOptions = controller.getCountries();
        TestOptions = controller.getCountriesList();
        TestOptions = controller.getCompanies();
        TestOptions = controller.getJobTitles();
        //TestOptions = controller.getQualifications();
        TestOptions = controller.getGenders();
        TestOptions = controller.getTitles();
        TestOptions = controller.getVisaPeriod();
        //TestOptions = controller.getHoldUAEPermit();
        TestOptions = controller.getMaritalStatuses();
        TestOptions = controller.getReligions();
        TestOptions = controller.getPortOfEntries();
        TestOptions = controller.getTitles();
        TestOptions = controller.getVisaPeriod();
        
        //pvv_ctlr.Initializevariables();
        controller.testFlagMark();
        
        PageReference Pg;
        Pg = controller.ResetApplication();
        Pg = controller.ToMainMenu();
        controller.Application.TAMM_VIP_Service__c = true;
        controller.Application.Visa_Period__c = '30 Days';
        controller.Application.Hold_UAE_Permit__c = 'Yes';
        controller.application.Port_of_Entry__c = 'Dubai International Airport';
        controller.application.Title__c = 'Mr';
        controller.application.First_Name__c = 'Cloud';
        controller.application.Middle_Name__c = 'S';
        controller.application.Last_Name__c = 'Concept';
        controller.application.Currently_Nationality__c = Countries.id;
        controller.application.Previous_Nationality__c = Countries.id;
        controller.application.Country_of_Birth__c = CountriesList.id;
        controller.application.City_of_Birth__c = 'SomePlace';
        controller.Application.Passport_Type__c = pt.id;
        controller.application.Passport_Number__c = '2345678AS';
        controller.application.Passport_Country_of_Issue__c = CountriesList.id;
        controller.application.Passport_City_of_Issue__c = 'SOMECITY';        
        controller.application.Mother_Full_Name__c = 'SOMENAME';
        controller.application.Marital_Status__c = 'Married';
        controller.application.Religion__c = 'bahaei';
        controller.Application.Job_Title_Position__c = OCP.id;
        controller.Application.Education_Qualification__c = QualificationsList.id;
        controller.Application.Gender__c = 'female';
        controller.Application.Company_Name__c = acc.id;
        controller.Application.Company_Point_Of_Contact_Mobile_Number__c = '23456789';
        controller.Application.Company_Index_Card_Number__c = '123';
        controller.Application.Name_of_Authorized_Signatory__c = 'SOMEONE';
        controller.Application.VRF_Verify1__c = true;
        controller.Application.VRF_Verify2__c = true;
        string dateBirth1  = String.valueOf(System.Today().addyears(1)); 
        dateBirth1 = string.valueOf(dateBirth1.split('-')[2]+'/'+dateBirth1.split('-')[1]+'/'+dateBirth1.split('-')[0]);
        
        controller.dateOfBirth = dateBirth1;
        controller.passportIssueDate = dateBirth1;
        controller.passportIssueDate = dateBirth1;
        controller.passportExpiryDate = dateBirth1;
        //controller.companyDate = dateBirth1;
        
        //Now calling method for create applicaiton..
        controller.CreateApplication();
        
    }

    public static testMethod void testMyController3()  // 90 days test
    { 
       //centralized data create
      Account acc = cls_CreateTestRecords.createAccount(); 
      Country__c Countries = cls_CreateTestRecords.createCountries();
      Occupation__c OCP = cls_CreateTestRecords.createOccupation();
      Qualification__c QualificationsList = cls_CreateTestRecords.createQualiciation();
      Passport_Type__c pt = cls_CreateTestRecords.createPassportType();
      CountriesList__c CountriesList = cls_CreateTestRecords.createCountriesList();
        //cls_CreateTestRecords.createFormRecords1();
          
 
        PageReference pageRef = Page.pvv;
        Test.setCurrentPage(pageRef);
        pvv_ctlr controller = new pvv_ctlr();
        
        List<SelectOption> TestOptions = new List<SelectOption>();
        //TestOptions = controller.getPassportTypes();
        TestOptions = controller.getCountries();
        TestOptions = controller.getCountriesList();
        TestOptions = controller.getCompanies();
        TestOptions = controller.getJobTitles();
        //TestOptions = controller.getQualifications();
        TestOptions = controller.getGenders();
        TestOptions = controller.getTitles();
        TestOptions = controller.getVisaPeriod();
        //TestOptions = controller.getHoldUAEPermit();
        TestOptions = controller.getMaritalStatuses();
        TestOptions = controller.getReligions();
        TestOptions = controller.getPortOfEntries();
        TestOptions = controller.getTitles();
        TestOptions = controller.getVisaPeriod();
        
        //pvv_ctlr.Initializevariables();
        controller.testFlagMark();
        
        PageReference Pg;
        Pg = controller.ResetApplication();
        Pg = controller.ToMainMenu();
        controller.Application.Visa_Period__c = '90 Days';
        controller.Application.Hold_UAE_Permit__c = 'Yes';
        controller.application.Port_of_Entry__c = 'Dubai International Airport';
        controller.application.Title__c = 'Mr';
        controller.application.First_Name__c = 'Cloud';
        controller.application.Middle_Name__c = 'S';
        controller.application.Last_Name__c = 'Concept';
        controller.application.Currently_Nationality__c = Countries.id;
        controller.application.Previous_Nationality__c = Countries.id;
        controller.application.Country_of_Birth__c = CountriesList.id;
        controller.application.City_of_Birth__c = 'SomePlace';
        controller.Application.Passport_Type__c = pt.id;
        controller.application.Passport_Number__c = '2345678AS';
        controller.application.Passport_Country_of_Issue__c = CountriesList.id;
        controller.application.Passport_City_of_Issue__c = 'SOMECITY';        
        controller.application.Mother_Full_Name__c = 'SOMENAME';
        controller.application.Marital_Status__c = 'Married';
        controller.application.Religion__c = 'bahaei';
        controller.Application.Job_Title_Position__c = OCP.id;
        controller.Application.Education_Qualification__c = QualificationsList.id;
        controller.Application.Gender__c = 'female';
        controller.Application.Company_Name__c = acc.id;
        controller.Application.Company_Point_Of_Contact_Mobile_Number__c = '23456789';
        controller.Application.Company_Index_Card_Number__c = '123';
        controller.Application.Name_of_Authorized_Signatory__c = 'SOMEONE';
        controller.Application.VRF_Verify1__c = true;
        controller.Application.VRF_Verify2__c = true;
        string dateBirth1  = String.valueOf(System.Today().addyears(1)); 
        dateBirth1 = string.valueOf(dateBirth1.split('-')[2]+'/'+dateBirth1.split('-')[1]+'/'+dateBirth1.split('-')[0]);
        controller.Application.DRV_Relation_with_Sponser__c = 'Sister'; 
        controller.Application.Gender__c = 'Female' ;
        controller.Application.DRV_Sponser_Title__c = 'Mr';
        controller.Application.DRV_Sponser_First_Name__c = 'Ahmed' ; 
        controller.Application.DRV_Sponser_Middle_Name__c = 'Adel' ;
        controller.Application.DRV_Sponser_Last_Name__c = 'Taha' ;
        controller.Application.DRV_Sponser_Currently_Nationality__c = Countries.Id;
        controller.Application.DRV_Sponser_Home_Phone__c = '2112121' ;
        controller.Application.DRV_Sponser_Office_Phone__c = '2112' ;
        controller.Application.DRV_Sponser_Visa_Number_1__c = '111';
        controller.Application.DRV_Sponser_Visa_Number_2__c = '222';
        controller.Application.DRV_Sponser_Visa_Number_3__c = '333';
        controller.Application.DRV_Sponser_Passport_Number__c = '12';
        controller.Application.DRV_Sponser_Company_Name__c = acc.Id;
        controller.SponserPassportExpiry = '01/02/2000' ;//String.ValueOf(Date.TODAY());
        controller.SponserResidencyExpiry = '01/02/2000' ;//String.ValueOf(Date.TODAY());
        controller.SponserDate = '01/02/2000' ;//String.ValueOf(Date.TODAY());
        
        controller.dateOfBirth = dateBirth1;
        controller.passportIssueDate = dateBirth1;
        controller.passportIssueDate = dateBirth1;
        controller.passportExpiryDate = dateBirth1;
        //controller.companyDate = dateBirth1;
        
        //Now calling method for create applicaiton..
        controller.CreateApplication();
        
        
    }
    
}